import {RequestHandler} from 'express'
import 'reflect-metadata'

export function middleware(middleware: RequestHandler) {
    return function (targetPrototype: any, methodname: string) {
        let middlewares = Reflect.getMetadata("middlewares", targetPrototype, methodname);
        if (!middlewares) {
            middlewares = [];
        }
        middlewares.push(middleware);
        Reflect.defineMetadata("middlewares", middlewares, targetPrototype, methodname);
    }
}
